<template>
  <div id="cart">
    <navbar class="navbar">
      <template v-slot:center>
        <div>购物车({{ cartLength }})</div>
      </template>
    </navbar>
    <scroll class="content" ref="scroll">
      <cart-list></cart-list>
    </scroll>
    <cart-bottom-bar></cart-bottom-bar>
  </div>
</template>

<script>
import { mapGetters } from "vuex";

import Navbar from "components/common/navbar/Navbar";
import scroll from "components/common/scroll/Scroll";

import cartList from "./childCart/cartList";
import cartBottomBar from "./childCart/cartBottemBar";

export default {
  name: "Cart",
  components: {
    Navbar,
    cartList,
    scroll,
    cartBottomBar,
  },
  activated() {
    this.$refs.scroll.refresh();
  },
  computed: {
    //mapGetters将store中的getters中的函数转化位计算属性直接用
    ...mapGetters({
      cartLength: "cartLength",
    }),
  },
};
</script>

<style scoped>
#cart {
  position: relative;
  height: 100vh;
}
.navbar {
  background-color: var(--color-tint);
  color: #fff;
  font-weight: 700;
}
.content {
  position: absolute;
  top: 44px;
  left: 0px;
  right: 0px;
  bottom: 93px;
}
</style>